#pragma once

#include <iostream>
#include <vector>
#include <ctime>

typedef void (*task_t)();

void PrintLog()
{
    std::cout<<"我是一个打印日志的任务"<<std::endl;
}

void Upload()
{
    std::cout<<"我是上传的任务"<<std::endl;
}

void DownLoad()
{
    std::cout<<"我是下载的任务"<<std::endl;
}
class TaskManager
{
private:
    std::vector<task_t> task;    
public:
    TaskManager()
    {
        srand(time(nullptr));
    }
    //加入执行任务
    void Register(task_t t)
    {
        task.push_back(t);
    }
    //产生任务码
    int code()
    {
        return rand() % task.size();
    }
    //执行任务
    void Executable(int code)
    {
        if(code >=0 && code < task.size())
        {
            task[code]();
        }
    }
    
    ~TaskManager()
    {}
};
